clear
load('selected_obj.mat');
load('vehicles_shortest.mat');
javaaddpath('C:\Program Files\Weka-3-6\weka.jar')

data = [];
features = [];
for i=1:1008
    data = horzcat(data,vehicles(i).selected_hog_features);
    data = horzcat(data,(vehicles(i).selected_wave_features)');
    features = vertcat(features,data);
    data = [];
end

class = [];
value = [];
%class = {'front', 'front', 'front' , 'side', 'side','side','rear','rear','rear'};
class = [-1 -1 -1 -2 -2 -2 -3 -3 -3];
for i=1:112
    value = horzcat(value,class); 
end
value = value';
obj =features;
obj = horzcat(obj, value);

allAttr={};
types={};
for i=1:127
   allAttr = [allAttr {strcat('hog',num2str(i))}];
   types = [types {'numeric'}];
end
for i=1:127
   allAttr = [allAttr {strcat('wavlet',num2str(i))}];
   types = [types {'numeric'}];
end

allAttr = [allAttr {'class'}];
types = [types {'numeric'}];
%arffwrite('foo.arff','test',allAttr,types,obj);
wekaobj = matlab2weka('foo',allAttr,obj);
%modle = trainWekaClassifier(wekaobj,'functions.SMO','-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K "weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0"');
%saveARFF('foofoo.arff',wekaobj);
traing = loadARFF('foofoo1.arff');
model = trainWekaClassifier(traing,'functions.SMO','-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K "weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0"');
[predictedClass, classProbs] = wekaClassify(traing,model)